function updateDom (that, isInit = false) {
    const div = document.querySelector('#a');
    const key = div.getAttribute('v-bind');
    div.innerText = that[key];

    if (!isInit) {
        return;
    }
    const btn = document.querySelector('button');
    const eventInfo = btn.getAttribute('v-on');
    const [eventType, eventFuncName] = eventInfo.split(':');
    btn.addEventListener(eventType, that[eventFuncName].bind(that));
}

function vue (config) {
    const data = config.data();
    const record = { ...data };

    const that = {
        ...config,
        ...data,
        ...config.methods,
    };

    for (const key in data) {
        Object.defineProperty(that, key, {
            // 设置
            set (newValue) {
                record[key] = newValue;
                config.beforeUpdate();
                updateDom(that);
                config.updated();
            },
            get () {
                return record[key];
            },
        });
    }

    config.beforeMount();
    // 初始化
    updateDom(that, true);
    config.mounted();
}

// svelte
